stage.set_background("halfcourt")
sprite = codesters.Sprite("player4")
sprite.go_to(215, -175)
net = codesters.Sprite("basketballnet")
net.go_to(215, 175)
ball = codesters.Sprite("basketball")
x = random.randint(-100, 150)
ball.go_to(x, -25)
stage.set_gravity(10)
stage.set_bounce(.8)
t = codesters.Teacher()
params = t.find_text('set_gravity_off')
# try:
# tval1 = params[0][1]
# except:
# tval1 = "DNE"
try:
tval2 = params[0][1]
except:
tval2 = "DNE"
try:
tval3 = params[1][1]
except:
tval3 = "DNE"
# t1 = TestObjective()
# t1.add_success('sprite' in tval1, "Great job!")
# t1.add_failure(tval1 == "DNE", "Did you turn off gravity for the sprite?")
t2 = TestObjective()
t2.add_success('ball' in tval2 or 'ball' in tval3, "Great job!")
t2.add_failure(tval2 == "DNE", "Did you turn off gravity for the ball and the net?")
t3 = TestObjective()
t3.add_success('net' in tval2 or 'net' in tval3, "Great job!")
t3.add_failure(tval3 == "DNE", "Did you turn off gravity for the ball and the net?")
tester = TestManager()
tester.add_test_list([t2, t3])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
提交作品
-
下个活动
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)